<?php
@session_start();
include "../../../jerimum/classes/bd.php";
include "../../../jerimum/classes/perguntas.php";

$cliente	= $_SESSION['idcliente'];

$_per 	= new perguntas();

$acao	= $_REQUEST["acao"];
$id		= $_REQUEST["id"];
$dados	= $_per->pega($id);

switch($acao){
			
		case "status":
		$_per->id		= $id;
		$_per->ativo 	= $_POST["ativo"];
		$ativa	= $_per->status();
		if($ativa){
			header("Location: detalhes.php?pergunta=".$id."");
			}else{ 
			header("Location: detalhes.php?pergunta=".$id."&erro=1");
			}
		break;
		
		
		
		break;
		
		
		case "apagaresposta":
		$idresposta		= $_GET["id"];
		$_per->apagapergunta($idresposta);
		
		header("Location: detalhes.php?pergunta=".$idresposta."");
		
		break;


		case "apagar":
		$_per->id		= $id;
		$finalizar	= $_per->deleta();
		
		if($finalizar){
		echo "1";
		}else{
		echo "0";
		}
		
		break;
				
		
}


?>